package com.dk.service.serviceImpl;

import com.dk.mapper.TagMapper;
import com.dk.pojo.Tag;
import com.dk.service.TagService;
import com.jack.weChatSecurity.core.spring.annotation.CheckRole;
import com.jack.weChatSecurity.core.spring.annotation.CheckRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@CheckRoles({"boss","worker"})
public class TagServiceImpl implements TagService {

    @Autowired
    TagMapper tagMapper;

    @CheckRole({"worker","manager"})
    public Tag addTag(String value)throws Exception{
        Tag tag=tagMapper.queryTagByValue(value);
        if(tag==null){
            tag=new Tag();
            tag.setValue(value);
            tagMapper.addTag(tag);
        }
        return tag;
    }

    public List<Tag> getTags(){
        return tagMapper.queryAllTags();
    }
}
